<?php
namespace Mobile\Widget;
use Think\Controller;
use Mobile\Model\adsModel;

class AdsWidget extends Controller {
    
    public $adsModel;
    
    public function __construct() {
        parent::__construct();
        $this->adsModel = new adsModel();
    }
    
    /*
     *广告位1
     */
    public function pic($touser){
        layout(false);
        $where = array(
            'atype' => 1,
            'status' => 1,
        );
        $ads = $this->adsModel->getAds($where);
        if($ads){
            $this->assign('ads',$ads);
            $this->assign('touser',$touser);
            $this->display("Ads/pic");
        }
    }
    
    /*
     * 个人资料广告位
     */
    public function user($touser){
        layout(false);
        if(!empty($touser)){
            $this->assign('touser',$touser);
            $this->display("Ads/user");
        }
    }
    
    /*
     * 个人资料广告位
     */
    public function jiangshi($article){
        layout(false);
        if($article['author_uid']){
            $this->assign('article',$article);
            $this->display("Ads/jiangshi");
        }
    }
    
    /*
     * 悬浮广告
     */
    public function xuanfu($touser,$memberinfo,$goods){
        layout(false);
        //广告类型:1纯图片 ,2方形小图+文字标题+文字描述 3.悬浮广告
        $where = array(
            'atype' => 3,
            'status' => 1,
        );
        
        $ads = $this->adsModel->getAds($where);
        if($ads){
            $this->assign('ads',$ads);
            $this->assign('touser',$touser);
            $this->assign('goods',$goods);
            if(!empty($goods) && ($memberinfo['grade_id']<2)){
                //商品类型
                $this->display("Ads/goodsxuanfu");
            }else{
                //非商品类型
                $this->display("Ads/xuanfu");
            }
            
        }
    }
    
     
}